package fyp.spedmew.connector;

import android.os.AsyncTask;
import android.util.Log;

import java.io.IOException;

import fyp.spedmew.backend.entity.checkInEndpoint.model.CheckIn;
import fyp.spedmew.backend.entity.jobEndpoint.model.Job;

public class CheckInInsertATask extends AsyncTask<CheckIn, Void, Boolean> {
    private static final String TAG = new Object(){}.getClass().getCanonicalName();

    @Override
    protected Boolean doInBackground(CheckIn... params) {
        try {
            if (params.length > 0 && params[0] != null) {
                ApiService.getCheckInEndpoint().insertCheckIn(params[0]).execute();
            } else {
                throw new IllegalAccessException("No CheckIn params");
            }
        } catch (IOException e ) {
            Log.e(TAG, Log.getStackTraceString(e));
            return Boolean.FALSE;
        } catch (IllegalAccessException e) {
            Log.e(TAG, Log.getStackTraceString(e));
            return Boolean.FALSE;
        }
        return Boolean.TRUE;
    }
}
